﻿//===================================================================================
// SPrello - sprello.codeplex.com
// A SharePoint ui inspired by trello.com
//===================================================================================
// Copyright (c) 2011-14 Pentalogic Technology Ltd. All rights reserved.
// THIS CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE.
//===================================================================================

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.WebControls;
using System.Web.UI;
using System.Reflection;

namespace SPrello.SPrello
{
    /// <summary>
    /// About EditorPart (aka ToolPart)
    /// </summary>
    public class AboutToolPart : EditorPart
    {
        // See http://www.wictorwilen.se/Post/Web-Part-Properties-part-2-Editor-Parts.aspx for tutorial

        public AboutToolPart()
        {
            this.Title = "About";
            this.ChromeState = PartChromeState.Minimized;
        }

        protected override void Render(HtmlTextWriter writer)
        {
            writer.Write("<h2><a target='_blank' href='http://sprello.codeplex.com/'>SPrello</a></h2>");            

            writer.Write("<p><a target='_blank' href='http://sprello.codeplex.com/'> - A SharePoint UI inspired by </a><a href='http://trello.com' target='blank'>Trello.com</a></p>");

            writer.Write("<br />");
            writer.Write("<p style='text-align:center'><em>By <strong><a target='_blank' href='http://www.pentalogic.net/?utm_source=toolpart&utm_medium=app&utm_campaign=SPrello&utm_content=about'>Pentalogic - web parts for Microsoft SharePoint</a></strong></em></p>");
            writer.Write("<br />");

            writer.Write("<p style='text-align:center; font-size:x-small;'>Copyright &copy; 2011-14<br>Pentalogic Technology Ltd.</p>");
            writer.Write("<p style='text-align:center; font-size:xx-small;'>Version : {0}</p>", AssemblyFileVersion);
            writer.Write("<br />");            

            base.Render(writer);
        }

        /// <summary>
        /// Used by the EditorPart to get the values from the web part into the controls
        /// </summary>
        public override void SyncChanges()
        {
            // Nothing to do, just about page.
        }

        public override bool ApplyChanges()
        {
            // Nothing to do, its just an about page!
            return true;
        }

        /// <summary>
        /// Gets the AssemblyFileVersion of the assembly in format major.minor.release format
        /// </summary>
        private static string AssemblyFileVersion
        {
            get
            {                
                return AssemblyInfo.AssemblyFileVersion;
            }
        }

    }
}
